<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>BOM: location</title>
        <style type="text/css">
            .wrapper{ width: 80%; margin: auto ; border: 1px solid gray ; }
            .wrapper>div { margin: 10px; border: 1px solid blue ; padding: 10px;}
        </style>
    </head>
    <body>

        <button onclick="changeHref()">通过修改 localtion 的 href 来跳转页面</button>

        <button onclick="myAssign()">通过调用 localtion.assign( url ) 来跳转页面</button>

        <button onclick="myReplace()">通过调用 localtion.replace( url ) 来跳转页面</button>

        <button onclick="myReload()">通过调用 localtion.reload() 来刷新页面</button>

        <p></p>

        <script type="text/javascript">

            const url = 'http://www.kaifamiao.com' ;

            function changeHref(){
                location.href = url ;
            }

            function myAssign(){
                location.assign( url );
            }

            function myReplace(){
                location.replace( url );
            }

            function myReload(){
                location.reload();
            }

            const p = document.querySelector( 'p' );
            p.innerHTML = new Date().toISOString();
        </script>
        
    </body>
</html>